package droid.frame.activity.base;

import android.app.Activity;
import android.view.View;
import android.view.ViewStub;

/**
 * 
 * @author coffee<br>
 *         2017-1-5下午12:02:30
 */
public class BaseViewStub {

	private Activity context;

	private ViewStub mViewStub;

	/**
	 * ViewStub加载的layout的根布局
	 */
	private View layout;

	public BaseViewStub(Activity context, int resId) {
		this.context = context;
		mViewStub = (ViewStub) context.findViewById(resId);
	}

	protected View findViewById(int id) {
		return context.findViewById(id);
	}

	/**
	 * 只能 infate一次, 然后ViewStub对象会被置为null
	 */
	protected void inflate() {
		layout = mViewStub.inflate();
	}

	public Activity getContext() {
		return context;
	}

	public void setVisibility(){
		
	}
	
	/**
	 * 销毁, Activity{@link #onDestroy()}的时候调用
	 */
	public void onDestroy() {
		if(layout != null){
			layout.setVisibility(View.GONE);
		}
	}
}
